import '../model/user_model.dart';

/// 用户默认数据
/// 提供8个植物养殖相关的用户数据
class UserData {
  /// 获取所有默认用户数据
  static List<UserModel> getDefaultUsers() {
    return [
      const UserModel(
        id: '1',
        username: 'admin',
        password: '123456',
        nickname: 'Green',
        avatar: 'assets/images/avatar1.png',
        signature:
            'Growing plants is my passion, every leaf tells a story of growth and care.',
      ),
      const UserModel(
        id: '2',
        username: 'gardenmaster',
        password: 'password123',
        nickname: 'Garden',
        avatar: 'assets/images/avatar2.png',
        signature:
            'From seed to bloom, I nurture every plant with love and patience.',
      ),
      const UserModel(
        id: '3',
        username: 'leafyfriend',
        password: 'password123',
        nickname: 'Botany',
        avatar: 'assets/images/avatar3.png',
        signature:
            'Creating green sanctuaries one plant at a time, nature is my teacher.',
      ),
      const UserModel(
        id: '4',
        username: 'plantcare',
        password: 'password123',
        nickname: 'Wizard',
        avatar: 'assets/images/avatar4.png',
        signature:
            'Every plant has its own personality, I help them thrive and flourish.',
      ),
      const UserModel(
        id: '5',
        username: 'greensoul',
        password: 'password123',
        nickname: 'Sage',
        avatar: 'assets/images/avatar5.png',
        signature:
            'Connecting with nature through plants, finding peace in every leaf.',
      ),
      const UserModel(
        id: '6',
        username: 'blooming',
        password: 'password123',
        nickname: 'Flower',
        avatar: 'assets/images/avatar6.png',
        signature:
            'Watching plants grow is like watching magic happen every single day.',
      ),
      const UserModel(
        id: '7',
        username: 'plantlife',
        password: 'password123',
        nickname: 'Garden',
        avatar: 'assets/images/avatar7.png',
        signature:
            'Plants are my therapy, they teach me patience and bring me joy.',
      ),
      const UserModel(
        id: '8',
        username: 'naturelover',
        password: 'password123',
        nickname: 'Hero',
        avatar: 'assets/images/avatar8.png',
        signature:
            'Building a green world one plant at a time, nature is my inspiration.',
      ),
    ];
  }

  /// 根据ID获取用户
  static UserModel? getUserById(String id) {
    final users = getDefaultUsers();
    try {
      return users.firstWhere((user) => user.id == id);
    } catch (e) {
      return null;
    }
  }

  /// 根据用户名获取用户
  static UserModel? getUserByUsername(String username) {
    final users = getDefaultUsers();
    try {
      return users.firstWhere((user) => user.username == username);
    } catch (e) {
      return null;
    }
  }

  /// 根据昵称获取用户
  static UserModel? getUserByNickname(String nickname) {
    final users = getDefaultUsers();
    try {
      return users.firstWhere((user) => user.nickname == nickname);
    } catch (e) {
      return null;
    }
  }
}
